<?php

namespace App\Module\Api\Controllers;

use App\System\Fina\Repositories\FinaScholarshipRepository;
use Illuminate\Http\Request;


class InviteListController extends Controller
{
    public function index()
    {
        $cache = \Cache::get(\request()->s);
        $userId = $cache['userInfo']->id;
//        根据用户id获取奖学金流水中的
        $user = FinaScholarshipRepository::getInstance();
//        根据用户id查询邀请记录
        $finaRecord = $user->getUserInvite($userId);
        $records = [
            'total'=>$finaRecord->count(),
        ];
        $finaRecord = $finaRecord->toArray();
        foreach ($finaRecord as $k=>$v){
            $record['id']= $v['id'];
            $record['bouns'] = $v['cash'];
            $record['created_at'] = $v['created_at'];
            $records['inviteList'][]=$record;
        }
        return $records;
    }
}
